{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>{:input('name')}的订单</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content infinite-scroll-content">

            <div class="order-list">
            </div>
            {include file='public:loading' /}

        </div>


    </div>
</div>
{/block}

{block name="js"}
<script>
    function getList() {
        var total = $('.order-list .li').length;
        if (total % 10 != 0) {
            return false;
        }

        if ($('.loading').is(':visible') || $('.no-more').is(':visible') || $('.no-data').is(':visible')) {
            return false;
        }
        $('.loading').show();

        var p = total / 10;
        $.post("{:url('order/getOrderList')}", {user_id:'{:input("user_id")}',type:2,page:p+1, shop_id:'{$shop_id}'}, function(data){
            $('.loading').hide();
            if (data.data.num > 0) {
                if (data.data.num < 10) {
                    $('.no-more').show();
                }
                $(data.data.html).appendTo($('.order-list'));
            } else {
                if (total > 0) {
                    $('.no-more').show();
                } else {
                    $('.no-data').show();
                }
            }
        }, 'json');
    }
    $(function(){
        getList();
    });
    //触发无限滚动
    $$('.infinite-scroll-content').on('infinite', function () {
        getList();
    });
</script>
{/block}